package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-03-19
 * Time: 10:33
 */
class Base {
    public int a = 8;
    public int b;
    public void methodB() {
        System.out.println("mB");
    }

}
class Derived extends Base {
    public int a = 199;
    public void methodD() {
        System.out.println(a);//优先访问子类自己的
        System.out.println(super.a);//super这个关键字可以访问父类成员
        System.out.println(b);
        //System.out.println(c);
    }
    public void methodB(char c) {
        System.out.println("char");

    }
    public void methodB() {
        System.out.println("nochar");
    }
    public void test() {
        super.methodB();
        methodB();
        methodB('a');
    }
}
public class Testdemo2 {
    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.test();
        //derived.methodD();
        //System.out.println(derived.a);//优先访问子类自己的
    }
}
